import { InjectRepository } from '@nestjs/typeorm'
import { Injectable } from '@angular/core'
import { CoreAli } from './ali.entity'
import { Repository } from 'typeorm'

@Injectable()
export class AliServer {
  constructor(@InjectRepository(CoreAli) public ali: Repository<CoreAli>) {}

  async addAli({ name, accessKeyID, accessKeySecret }) {
    const ali = new CoreAli()
    ali.name = name
    ali.accessKeySecret = accessKeySecret
    ali.accessKeyID = accessKeyID
    await this.ali.save(ali)
    return ali
  }

  async getAliList() {
    return await this.ali.find({})
  }
}
